import type { PageParams, PageResult } from '@/types/global'
import type { BannerItem, CategoryItem, GuessItem, HotItem } from '@/types/home'
import { http, ajhttp } from '@/utils/http'

/**
 * 首页-广告区域-小程序
 * @param distributionSite 广告区域展示位置 默认是1, 其他再定
 */
export const getHomeBannerAPI = (distributionSite = 1) => {
  return ajhttp({
    method: 'GET',
    url: '/system/config/banners',
    data: {
      distributionSite,
    },
  })
}

/**
 * 首页-前台分类-小程序
 */
export const getHomeCategoryAPI = () => {
  // return http<CategoryItem[]>({
  //   method: 'GET',
  //   url: '/home/category/mutli',
  // })
  return new Promise((ok, _) => {
    setTimeout(() => {
      ok({
        result: [{
          id: '1',
          icon: '/static/images/icon-mobile.png',
          name: '趣玩家',
          clickHandle: () => {
            uni.navigateTo({
              url: '/pages/performer/category-list'
            })
          }
        }, {
          id: '2',
          icon: '/static/images/icon-tpl.png',
          name: '文创园',
          clickHandle: () => {
            uni.navigateTo({
              url: '/pages/shop/category-list'
            })
          }
        }, {
          id: '4',
          icon: '/static/images/icon-wxmp.png',
          name: '商家服务',
          clickHandle: () => {
            uni.navigateTo({
              url: '/pages/shop/service-category'
            })
          }
        },{
          id: '5',
          icon: '/static/images/icon-wxmp.png',
          name: '关于我们',
          clickHandle: () => {
            uni.navigateTo({
              url: '/pages/public/article?search=关于我们'
            })
          }
        }]
      })
    }, 1200);
  })
}

/**
 * 首页-热门推荐-小程序
 */
export const getHomeHotAPI = () => {
  // return http<HotItem[]>({
  //   method: 'GET',
  //   url: '/home/hot/mutli',
  // })
  return new Promise((ok, _) => {
    setTimeout(() => {
      ok({
        result: [{
          id: '1',
          title: '基础商城',
          alt: '快速搭建',
          pictures: ['https://www.alphabot.center/content/images/demo/prod-shop01.jpg', 'https://www.alphabot.center/content/images/demo/prod-shop02.jpg'],
          type: 1
        }, {
          id: '2',
          title: '广场社交',
          alt: '好友分享',
          pictures: ['https://www.alphabot.center/content/images/demo/prod-task01.jpg', 'https://www.alphabot.center/content/images/demo/prod-task02.jpg'],
          type: 2
        }, {
          id: '3',
          title: 'CMS',
          alt: '客户/人员管理',
          pictures: ['https://www.alphabot.center/content/images/demo/prod-employee01.jpg', 'https://www.alphabot.center/content/images/demo/prod-employee02.jpg'],
          type: 3
        }, {
          id: '4',
          title: '桌面定制',
          alt: '高效管理',
          pictures: ['https://www.alphabot.center/content/images/demo/prod-shipping01.jpg', 'https://www.alphabot.center/content/images/demo/prod-shipping02.jpg'],
          type: 4
        }]
      })
    }, 1200);
  })
}

/**
 * 猜你喜欢-小程序
 */
export const getHomeGoodsGuessLikeAPI = (data?: PageParams) => {
  // return http<PageResult<GuessItem>>({
  //   method: 'GET',
  //   url: '/home/goods/guessLike',
  //   data,
  // })
  return new Promise((ok, _) => {
    setTimeout(() => {
      ok({
        result: {
          counts: 4,
          pageSize: 10,
          pages: 1,
          page: 1,
          items: [{
            id: '1',
            name: '快速商城框架(小程序/H5)',
            desc: '',
            price: 6480.00,
            picture: 'https://www.alphabot.center/content/images/demo/prod-shop01.jpg',
            orderNum: 1
          }, {
            id: '2',
            name: '社交广场类应用(小程序/H5)',
            desc: '',
            price: 9072.00,
            picture: 'https://www.alphabot.center/content/images/demo/prod-task01.jpg',
            orderNum: 2
          }, {
            id: '3',
            name: 'CMS人员管理(桌面版)',
            desc: '',
            price: 3960.00,
            picture: 'https://www.alphabot.center/content/images/demo/prod-employee01.jpg',
            orderNum: 3
          }, {
            id: '4',
            name: '管理系统定制(桌面版)',
            desc: '',
            price: 7920.00,
            picture: 'https://www.alphabot.center/content/images/demo/prod-shipping01.jpg',
            orderNum: 4
          }]
        }
      })
    }, 1200)
  })
}
